package com.proposition.commons.exam.result;

/**
 * @Author: 陈玉林
 * @Description: 处理结果工具类
 * @Date: Create In 16:46 2017/8/10
 * @ModifiedBy:
 */
public class ResultUtil {
    /**
     *@Author: 陈玉林
     *@Description: 成功，且需要返回结果
     *@Date: 2017/8/10 16:54
     */
    public static Result sucess(Object obj) {
        Result result = new Result();
        result.setCode(ResultEnum.SUCESS.getCode());
        result.setMsg(ResultEnum.SUCESS.getMsg());
        result.setData(obj);
        return result;
    }
    /**
     *@Author: 陈玉林
     *@Description: 成功，不需要返回结果
     *@Date: 2017/8/10 16:54
     */
    public static Result sucess() {
        Result result = new Result();
        result.setCode(ResultEnum.SUCESS.getCode());
        result.setMsg(ResultEnum.SUCESS.getMsg());
        return result;
    }
    /**
     *@Author: 陈玉林
     *@Description: 失败
     *@Date: 2017/8/10 16:54
     */
    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    /**
     *@Author: 陈玉林
     *@Date: 2017/8/11 14:44
     *@Description:
     */
    public static Result error(ResultEnum resultEnum) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }
}
